<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ page import="java.util.*"%>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="board.db.*" %>

<%
//System.out.println(request.getAttribute("listcount")+" "+request.getAttribute("page")+" "+request.getAttribute("maxpage")+" " +request.getAttribute("startpage")+" "+request.getAttribute("endpage"));

	List boardList=null;
	int listcount=1;
	int nowpage=1;
	int maxpage=1;
	int startpage=1;
	int endpage=1;
	
	if(request.getAttribute("listcount")==null)
	{
		response.sendRedirect("./BoardList.do");
	}
	else
	{
		boardList=(List)request.getAttribute("boardlist");
		listcount=((Integer)request.getAttribute("listcount")).intValue();
		nowpage=((Integer)request.getAttribute("page")).intValue();
		maxpage=((Integer)request.getAttribute("maxpage")).intValue();
		startpage=((Integer)request.getAttribute("startpage")).intValue();
		endpage=((Integer)request.getAttribute("endpage")).intValue();
%>


<%
    int pageSize = 8;
    SimpleDateFormat sdf = 
        new SimpleDateFormat("yyyy-MM-dd");


    String pageNum = request.getParameter("pageNum");
    if (pageNum == null) {
        pageNum = "1";
    }

    int currentPage = Integer.parseInt(pageNum);
    int startRow = (currentPage - 1) * pageSize + 1;
    int endRow = currentPage * pageSize;
    int count = 0;
    List photolist = null;
    
    
    
    %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>shopping your dream</title>

<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="default.css" rel="stylesheet" type="text/css" />
 
<script language="javascript" type="text/javascript"
    SRC="../board/board.js">
</script>
 
<head>
	<title>MVC 게시판</title>
</head>

<body>

<div id="logo-wrap">
<div id="logo">
<h1><a href="../harvest/index.jsp">Shop </a></h1>
<h2>Design your dream</h2>
</div>
</div>

<!-- start header -->
<div id="header">
<div id="menu">
  <ul id="tabSubmenu">
	<li><a href="#">SHOP</a>
	<ul>
		<li><a href="../web/shop/shop_shop/BoardList.sh">top</a></li>
        <li><a href="../web/shop/shop_shop/BoardListPants.sh">pants</a></li>
        <li><a href="../web/shop/shop_shop/BoardListOnepice.sh">onepice</a></li>
		<li><a href="#">skirt</a></li>
		<li><a href="#">dress</a></li>
		<li><a href="#">bag</a></li>
		<li><a href="#">etc</a></li>
	</ul>
	</li>
	<li><a href="#">TO OFFER</a>
	<ul>
		<li><a href="../web/shop/shop_offer/list.jsp">trend</a></li>
		<li><a href="#">style</a></li>
	</ul>
	</li>
	<li><a href="#">COMMUNITY</a>
	<ul>
		<li><a href="../board/qna_board_list.jsp">
		패션제안</a></li>
		<li><a href="../board/hot_girl_list.jsp">
		Hot girl</a></li>
	</ul>
	</li>
</ul>
<ul>
	<li><a href="../qna/indexMain.jsp">Q & A</a></li>
	<li><a href="#">MYPAGE</a></li>
	<li><a href="#">CART</a></li>
	<li class="current_page_item"><a href="../login.jsp">
	<%
	String sessionId = (String)session.getAttribute("shop_id"); 
	if(sessionId == null)
	{
	%>
	LOG IN
	<%
	}
	else
	{
	%>
	<%=sessionId %> LOG OUT
	<%
	}
	%></a></li>
	<li class="last"><a href="../join.jsp">
	<% 
	if(sessionId == null)
	{
	%>
	JOIN US
	<%
	}
	else
	{
	%>
	<%
	}
	%>
	</a></li>
</ul>
</div>
</div>
<!-- end header -->
<!-- start page -->
<div id="wrapper">
<div id="wrapper-btm">
<div id="page"><!-- start content -->
<h1 class="title" align="center">Hot Girl</h1>
<div id="content">
<div class="post">
</div>
<div class="post">
<div class="meta">
<p class="links"><a href="#" class="more">Read full article</a> <b>|</b>
<a href="#" class="comments">Comments (32)</a></p>

<!-- end content --> 
<!-- 게시판 리스트 -->
<table width=80% border="0" cellpadding="0" cellspacing="0" align="center">
	<tr align="right" valign="middle">
		<td align="right">
			<font size=2>글 개수 : ${listcount }</font>
		</td>
	</tr>
	
	<tr align="center" valign="middle" bordercolor="#333333">
		<td style="font-family:Tahoma;font-size:8pt;" width="8%" height="26">
			<div align="center">번호</div>
		</td>
		
		<td style="font-family:Tahoma;font-size:8pt;" width="30%" height="40">
			<div align="center">이미지</div>
		</td>
		<td style="font-family:Tahoma;font-size:8pt;" width="50%">
			<div align="center">제목</div>
		</td>
		<td style="font-family:Tahoma;font-size:8pt;" width="14%">
			<div align="center">작성자</div>
		</td>
		<td style="font-family:Tahoma;font-size:8pt;" width="17%">
			<div align="center">날짜</div>
		</td>
		<td style="font-family:Tahoma;font-size:8pt;" width="11%">
			<div align="center">조회수</div>
		</td>
	</tr>
	
	<%

		for(int i = 0; i<boardList.size(); i++) {  
			BoardBean pl=(BoardBean)boardList.get(i);
			%>

<td align="center"><a href =./DetailAction.do?num=<%=pl.getBOARD_NUM()%>&pageNum=<%=currentPage%>>
<div align="center">
<img src="C:\shopdesign\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\shopping mall\boardupload\<%=pl.getBOARD_FILE() %>"width="192" height="244" /><BR><%=pl.getBOARD_NAME() %></div>
	</td>
<a href ="./BoardDetailAction.do&pageNum=<%=currentPage%>">
</a><br/>
<td style="font-family:Tahoma;font-size:10pt;">
			<div align="left">
			<%if(pl.getBOARD_RE_LEV()!=0){ %>
				<%for(int a=0;a<=pl.getBOARD_RE_LEV()*2;a++){ %>
				&nbsp;
				<%} %>
				▶
			<%}else{ %>
				▶
			<%} %>
			<a href="./BoardDetailAction.do?num=<%=pl.getBOARD_NUM()%>">
				
				
			</a>
			</div>
		</td>
<%
if(i==4){ 
	%>
<tr><td height="9"></td></tr>
<%
}
} 
%>
</tr>
<%}%>
</table>

<center>



<%
int count=0;
int pageSize = 4;

String pageNum = request.getParameter("pageNum");
if (pageNum == null) {
    pageNum = "1";
}
int currentPage = Integer.parseInt(pageNum);
    if (count > 0) {
        int pageCount = count / pageSize + ( count % pageSize == 0 ? 0 : 1);
         
        int startPage = (int)(currentPage/10)*10+1;
        int pageBlock=10;
        int endPage = startPage + pageBlock-1;
        if (endPage > pageCount) endPage = pageCount;
        
        if (startPage > 10) {    %>
        <a href="kPhotoList.jsp?pageNum=<%= startPage - 10 %>"><img src="../img/btn/before_btn.gif"/></a>
<%      }
        for (int i = startPage ; i <= endPage ; i++) {  %>
        <a href="kPhotoList.jsp?pageNum=<%= i %>"><%= i %></a>
<%
        }
        if (endPage < pageCount) {  %>
        <a href="kPhotoList.jsp?pageNum=<%= startPage + 10 %>"><img src="../img/btn/next_btn.gif"/></a>
<%
        }
    }
%>
</center>

<tr align=center height=20>
		<td colspan=7 style=font-family:Tahoma;font-size:10pt;>
			<%if(nowpage<=1){ %>
			[이전]&nbsp;
			<%}else{ %>
			<a href="./BoardList.do?page=<%=nowpage-1 %>">[이전]</a>&nbsp;
			<%} %>
			
			<%for(int a=startpage;a<=endpage;a++){
				if(a==nowpage){%>
				[<%=a %>]
				<%}else{ %>
				<a href="./BoardList.do?page=<%=a %>">[<%=a %>]</a>&nbsp;
				<%} %>
			<%} %>
			
			<%if(nowpage>=maxpage){ %>
			[다음]
			<%}else{ %>
			<a href="./BoardList.do?page=<%=nowpage+1 %>">[다음]</a>
			<%} %>
		</td>
	</tr>
	<tr align="right">
		<td colspan="5">
	   		<a href="./BoardWrite.do">[글쓰기]</a>
		</td>
	</tr>
<!-- end footer -->
</div>
</div>
</div>
</div>
</div>
</body>
</html>